package com.yzc.user;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequiredArgsConstructor
@RequestMapping("/user")
public class UserController {

    final UserBeanServiceImpl userService;

    /**
     * 获取用户数据
     *
     * @return
     */
    @RequestMapping("/loadAll.do")
    public List<UserBean> loadAll() {
        return userService.loadaAll();
    }

    /**
     * 修改用户数据
     *
     * @return
     */
    @RequestMapping("/update.do")
    public Map updateInfo(@RequestBody UserBean userBean) {
        return userService.updateInfo(userBean);
    }

    @RequestMapping("/updateXinxi.do")
    public Map updateXinxi(@RequestBody UserBean userBean) {
        return userService.updateXinxi(userBean);
    }

    @RequestMapping("/updatePass.do")
    public Map updatePass(@RequestBody UserBean userBean) {
        return userService.updatePass(userBean);
    }

    /**
     * 更新用户数据
     *
     * @return
     */
    @RequestMapping("/save.do")
    public Map save(@RequestBody UserBean userBean) {
        return userService.saveInfos(userBean);
    }

    /**
     * 删除用户数据
     *
     * @return
     */
    @RequestMapping("/delete.do")
    public Map deleteInfo(UserBean userBean) {
        return userService.deleteInfo(userBean);
    }

    /**
     * 查询用户数据
     *
     * @return
     */
    @RequestMapping("/selectInfos.do")
    public List selectInfos(String name) {
        return userService.selectInfos(name);
    }

    /**
     * 根据id查询
     *
     * @return
     */
    @RequestMapping("/getInfoById.do")
    public UserBean getInfoById(String id) {
        return userService.getInfoById(id);
    }


}
